package com.learnJava.demo;

import java.util.Scanner;

public class MovieOperator {

    private Movie[] movies;

    public MovieOperator(Movie[] movies) {
        this.movies = movies;
    }

    public void printALlMovie() {
        for (Movie movie : movies) {
            System.out.println(movie.getId() + " " + movie.getName() + " " + movie.getActor() + " " + movie.getPrice());
        }
    }

    public void searchMovieById() {
        System.out.println("输入要查询的电影id：");
        Scanner sc = new Scanner(System.in);
        int id = sc.nextInt();
        for (Movie movie : movies) {
            if (movie.getId() == id) {
                System.out.println(movie.getName() + " " + movie.getActor() + " " + movie.getPrice());
                return ;
            }
        }
        System.out.println("没有找到该电影。");
    }
}
